/*
 * @Author: Zhouhai 497675647@qq.com
 * @Date: 2022-10-27 17:00:23
 * @LastEditors: Zhouhai 497675647@qq.com
 * @LastEditTime: 2022-12-01 17:22:03
 */
import request from '@/utils/request';
import type { UserDomain } from '@/type.d/system';



// 查询用户信息列表
export async function getUserList(params?: UserDomain) {
  return request(`/system/user/list`, {
    method: 'GET',
    params: params
  });
}

// 查询用户信息列表
export async function getUserSelectList(params?: UserDomain) {
  return request(`/system/user/selectlist`, {
    method: 'GET',
    params: params
  });
}

// 查询用户信息详细
export function getUser(userId: string) {
  return request(`/system/user/${userId}`, {
    method: 'GET',
  });
}


// 查询用户信息详细
export function getRoleCorpInfoByUserId(userId: string) {
  return request(`/system/user/authRoleCorp/${userId}`, {
    method: 'GET',
  });
}

// 新增用户信息
export async function addUser(params: UserDomain) {
  return request('/system/user', {
    method: 'POST',
    data: params,
  });
}

// 修改用户信息
export async function updateUser(params: UserDomain) {
  return request('/system/user', {
    method: 'PUT',
    data: params,
  });
}

// 删除用户信息
export async function removeUser(ids: string) {
  return request({
    url: `/system/user/${ids}`,
    method: 'delete'
  })
}


export function updateUserProfile(data: UserDomain) {
  return request('/system/user/profile', {
    method: 'put',
    data: data
  })
}

// 用户密码更新
export function updateUserPwd(oldPassword: string, newPassword: string) {
  const data = {
    oldPassword,
    newPassword
  }
  return request('/system/user/profile/updatePwd', {
    method: 'put',
    params: data
  })
}

// 用户密码重置
export function resetUserPwd(data: UserDomain) {
  return request('/system/user/resetPwd', {
    method: 'put',
    data
  })
}

// 用户头像上传
export function uploadAvatar(data: any) {
  return request('/system/user/profile/avatar', {
    method: 'post',
    data: data
  })
}